package com.bw.paper.mvp.view.Fragment.user.Adapter;

import android.widget.ImageView;

import com.bw.paper.R;
import com.bw.paper.entity.UserItemEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class UserAdapter extends BaseQuickAdapter<UserItemEntity, BaseViewHolder> {
    public UserAdapter() {
        super(R.layout.view_user_items);
        addChildClickViewIds(R.id.user_items_arrow_img);

    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, UserItemEntity userItemEntity) {

        baseViewHolder.setText(R.id.user_items_tv,userItemEntity.name);
        baseViewHolder.setBackgroundResource(R.id.user_items_arrow_img,R.drawable.you);

        ImageView imgon = baseViewHolder.itemView.findViewById(R.id.user_items_arrow_img);
//        imgon.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                userItemEntity.selFlag = !userItemEntity.selFlag;
//                if (userItemEntity.name.equals("夜间模式")){
//                    if (userItemEntity.selFlag){
//                        baseViewHolder.setBackgroundResource(R.id.user_items_arrow_img,R.drawable.new_on);
//
//                    }else {
//                        baseViewHolder.setBackgroundResource(R.id.user_items_arrow_img,R.drawable.new_off);
//
//                    }
//                }
//            }
//        });

        if (userItemEntity.name.equals("夜间模式")){
            if (userItemEntity.selFlag){
                baseViewHolder.setBackgroundResource(R.id.user_items_arrow_img,R.drawable.new_on);
            }else {
                baseViewHolder.setBackgroundResource(R.id.user_items_arrow_img,R.drawable.new_off);

            }
        }



    }
}
